#Luke Snyder
#Assignment 3
from sys import exit                                ## import the exit command
from types import *				    				##imports the types library
_contents = [[],[],[]]                              ## Stores the global list

class Set:                                          ## starts the class
    def __init__(self):                             ## Initial 
        self._contents = _contents                  ## copies the global list in a private veriable

    def add(self, addValue):                        ## function to add a value to the list
        self._inValue = addValue                    ## copies the input value
        if type(self._inValue) is IntType:			## next 5 lines finds the type of the input and then assignes the right list
            self._contents = Set()._contents[0]		
        if type(self._inValue) is StringType:
            self._contents = Set()._contents[1]
        if type(self._inValue) is FloatType:
            self._contents = Set()._contents[2]
        present = Set().__contains__(self._inValue)
        if present == False:                        ## if the value is not present add it
            self._contents.append(self._inValue)    ## addes value to list
        if type(self._inValue) is IntType: 
            Set()._contents[0] = self._contents     
        if type(self._inValue) is StringType:
            Set()._contents[1]  = self._contents
        if type(self._inValue) is FloatType:
            Set()._contents[2]  = self._contents

    def discard(self, discardValue):                ## function to remove value
        self._disValue = discardValue               ## copies input value
        if type(self._disValue) is IntType:			## next 5 lines finds the type of the input and then assignes the right list
            self._contents = Set()._contents[0]
        if type(self._disValue) is StringType:
            self._contents = Set()._contents[1]
        if type(self._disValue) is FloatType:
            self._contents = Set()._contents[2]
        try:                                        ## try statement to remove value
            self._contents.remove(self._disValue)   ## removes value from list
        except ValueError:                          ## if value is not present exit and do nothing
            exit                                    ## exit command from sys
        if type(self._disValue) is IntType: 		## next 5 lines finds the type of the input and then assignes the right list
            Set()._contents[0] = self._contents     
        if type(self._disValue) is StringType:
            Set()._contents[1]  = self._contents
        if type(self._disValue) is FloatType:
            Set()._contents[2]  = self._contents

    def __contains__(self, checkValue):             ## function to check if the list contains a value
        self._checkValue = checkValue               ## copies the input value        
        if type(self._checkValue) is IntType:    	## next 5 lines finds the type of the input and then assignes the right list   
            self._contents = Set()._contents[0]
        if type(self._checkValue) is StringType:
            self._contents = Set()._contents[1]
        if type(self._checkValue) is FloatType:
            self._contents = Set()._contents[2]
        for _i in self._contents:                   ## loop to check if value exists
            if _i == self._checkValue:              ## if value exists
                return True                         ## return True Boolean
        return False                                ## if does not exist return False Boolean



if __name__ == '__main__':
	numErrors = 0
	Set().add(30)
	Set().add("hello")
	Set().add(40.057)
	Set().add(50)
	Set().add("second string")
	Set().add(31337)
	Set().add(31.337)
	if len(_contents[0]) != 3:
		print "integers are not getting added!"
		numErrors += 1
	if len(_contents[1]) != 2:
		print "Strings are no getting added!"
		numErrors += 1
	if len(_contents[2]) != 2:
		print "floats are not getting added!"
		numErrors += 1
	Set().discard(30)
	if len(_contents[0]) != 2:
		print "values are not getting removed!"
		numErrors += 1
	Set().add(31337)
	if len(_contents[0]) != 2:
		print "Present values are being added!"
		numErrors += 1
	if numErrors == 0:
		print "No errors occured"
		print "List is expected to be"
		print "[50, 31337], ['hello', 'second string'], [40.057, 31.337]"
		print "list is:"
		print _contents
	else:
		print "list should be"
		print "[50, 31337], ['hello', 'second string'], [40.015, 31.337]"
		print "list is"
		print _contents




